// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Aggregations;

[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Aggregations.Json.MatrixStatsAggregationConverter))]
public sealed partial class MatrixStatsAggregation
{
#if NET7_0_OR_GREATER
	public MatrixStatsAggregation()
	{
	}
#endif
#if !NET7_0_OR_GREATER
	public MatrixStatsAggregation()
	{
	}
#endif
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	internal MatrixStatsAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel)
	{
		_ = sentinel;
	}

	/// <summary>
	/// <para>
	/// An array of fields for computing the statistics.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; }

	/// <summary>
	/// <para>
	/// The value to apply to documents that do not have a value.
	/// By default, documents without a value are ignored.
	/// </para>
	/// </summary>
	public System.Collections.Generic.IDictionary<Elastic.Clients.Elasticsearch.Field, double>? Missing { get; set; }

	/// <summary>
	/// <para>
	/// Array value the aggregation will use for array or multi-valued fields.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.SortMode? Mode { get; set; }
}

public readonly partial struct MatrixStatsAggregationDescriptor<TDocument>
{
	internal Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public MatrixStatsAggregationDescriptor(Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public MatrixStatsAggregationDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument>(Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation instance) => new Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument>(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation(Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument> descriptor) => descriptor.Instance;

	/// <summary>
	/// <para>
	/// An array of fields for computing the statistics.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument> Fields(Elastic.Clients.Elasticsearch.Fields? value)
	{
		Instance.Fields = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// An array of fields for computing the statistics.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument> Fields(params System.Linq.Expressions.Expression<System.Func<TDocument, object?>>[] value)
	{
		Instance.Fields = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The value to apply to documents that do not have a value.
	/// By default, documents without a value are ignored.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument> Missing(System.Collections.Generic.IDictionary<Elastic.Clients.Elasticsearch.Field, double>? value)
	{
		Instance.Missing = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The value to apply to documents that do not have a value.
	/// By default, documents without a value are ignored.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument> Missing()
	{
		Instance.Missing = Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldDouble<TDocument>.Build(null);
		return this;
	}

	/// <summary>
	/// <para>
	/// The value to apply to documents that do not have a value.
	/// By default, documents without a value are ignored.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument> Missing(System.Action<Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldDouble<TDocument>>? action)
	{
		Instance.Missing = Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldDouble<TDocument>.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument> AddMissing(Elastic.Clients.Elasticsearch.Field key, double value)
	{
		Instance.Missing ??= new System.Collections.Generic.Dictionary<Elastic.Clients.Elasticsearch.Field, double>();
		Instance.Missing.Add(key, value);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument> AddMissing(System.Linq.Expressions.Expression<System.Func<TDocument, object?>> key, double value)
	{
		Instance.Missing ??= new System.Collections.Generic.Dictionary<Elastic.Clients.Elasticsearch.Field, double>();
		Instance.Missing.Add(key, value);
		return this;
	}

	/// <summary>
	/// <para>
	/// Array value the aggregation will use for array or multi-valued fields.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument> Mode(Elastic.Clients.Elasticsearch.SortMode? value)
	{
		Instance.Mode = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation Build(System.Action<Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument>>? action)
	{
		if (action is null)
		{
			return new Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
		}

		var builder = new Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor<TDocument>(new Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}

public readonly partial struct MatrixStatsAggregationDescriptor
{
	internal Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public MatrixStatsAggregationDescriptor(Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public MatrixStatsAggregationDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor(Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation instance) => new Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation(Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor descriptor) => descriptor.Instance;

	/// <summary>
	/// <para>
	/// An array of fields for computing the statistics.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor Fields(Elastic.Clients.Elasticsearch.Fields? value)
	{
		Instance.Fields = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// An array of fields for computing the statistics.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor Fields<T>(params System.Linq.Expressions.Expression<System.Func<T, object?>>[] value)
	{
		Instance.Fields = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The value to apply to documents that do not have a value.
	/// By default, documents without a value are ignored.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor Missing(System.Collections.Generic.IDictionary<Elastic.Clients.Elasticsearch.Field, double>? value)
	{
		Instance.Missing = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The value to apply to documents that do not have a value.
	/// By default, documents without a value are ignored.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor Missing()
	{
		Instance.Missing = Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldDouble.Build(null);
		return this;
	}

	/// <summary>
	/// <para>
	/// The value to apply to documents that do not have a value.
	/// By default, documents without a value are ignored.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor Missing(System.Action<Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldDouble>? action)
	{
		Instance.Missing = Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldDouble.Build(action);
		return this;
	}

	/// <summary>
	/// <para>
	/// The value to apply to documents that do not have a value.
	/// By default, documents without a value are ignored.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor Missing<T>(System.Action<Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldDouble<T>>? action)
	{
		Instance.Missing = Elastic.Clients.Elasticsearch.Fluent.FluentDictionaryOfFieldDouble<T>.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor AddMissing(Elastic.Clients.Elasticsearch.Field key, double value)
	{
		Instance.Missing ??= new System.Collections.Generic.Dictionary<Elastic.Clients.Elasticsearch.Field, double>();
		Instance.Missing.Add(key, value);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor AddMissing<T>(System.Linq.Expressions.Expression<System.Func<T, object?>> key, double value)
	{
		Instance.Missing ??= new System.Collections.Generic.Dictionary<Elastic.Clients.Elasticsearch.Field, double>();
		Instance.Missing.Add(key, value);
		return this;
	}

	/// <summary>
	/// <para>
	/// Array value the aggregation will use for array or multi-valued fields.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor Mode(Elastic.Clients.Elasticsearch.SortMode? value)
	{
		Instance.Mode = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation Build(System.Action<Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor>? action)
	{
		if (action is null)
		{
			return new Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
		}

		var builder = new Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregationDescriptor(new Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}